package com.whfc.fuum.service.impl;

import com.whfc.fuum.dao.AppContractMapper;
import com.whfc.fuum.entity.AppContract;
import com.whfc.fuum.service.AppContractService;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.Date;
import java.util.List;

/**
 * 合同管理服务实现类
 */
@DubboService(interfaceClass = AppContractService.class, version = "1.0.0")
public class AppContractServiceImpl implements AppContractService {

    @Autowired
    private AppContractMapper appContractMapper;

    @Override
    public AppContract getById(Integer id) {
        return appContractMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<AppContract> list(Integer deptId, String contractName) {
        return appContractMapper.selectList(deptId, contractName);
    }

    @Override
    public boolean save(AppContract contract) {
        contract.setDelFlag(0);
        contract.setCreateTime(new Date());
        contract.setUpdateTime(new Date());
        return appContractMapper.insert(contract) > 0;
    }

    @Override
    public boolean update(AppContract contract) {
        contract.setUpdateTime(new Date());
        return appContractMapper.updateByPrimaryKey(contract) > 0;
    }

    @Override
    public boolean delete(Integer id) {
        return appContractMapper.deleteByPrimaryKey(id) > 0;
    }

    @Override
    public boolean deleteBatch(List<Integer> ids) {
        return appContractMapper.deleteBatch(ids) > 0;
    }
}
